<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var arr = [1, 2, 3, 4]
    Array.prototype.MyFindIndex = function (fn) {
        var newArray = 0;
        for (var i = 0; i < this.length; i++) {
            var item = fn(this[i], i, this);
            if (item) {
                newArray = newArray + i;
                break;
            } else {
                newArray = -1;
            }
        } return newArray
    }
    var a = arr.MyFindIndex(function (item, index, array) {
        return item > 2

    })
    console.log(a);
</script>

</html>